package com.tzm.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

public class TestServerInitializer extends ChannelInitializer<SocketChannel> {

    protected void initChannel(SocketChannel ch) throws Exception {
        //向管道加入处理器

        //从客户端的连接获取管道
        ChannelPipeline pipeline=ch.pipeline();
        //加入一个netty提供的httpServerCodec codec =》【coder - decoder】
        //HttpServerCodec说明
        //1.httpserverCodec 是netty提供的处理http的编解码器
        pipeline.addLast("MyHttpServerCodec",new HttpServerCodec());
        //增加一个自定义的handler
        pipeline.addLast("MyTestHttpServerHandler",new TestHttpServerHandler());

        System.out.println("ok~~~~~");
    }
}
